package flc.ast.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyTextBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class SelTextAdapter extends StkProviderMultiAdapter<MyTextBean> {

    public SelTextAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(50));
        addItemProvider(new SelTextProvider());
    }

    private class SelTextProvider extends BaseItemProvider<MyTextBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sel_text;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyTextBean bean) {
            baseViewHolder.setText(R.id.tvSelTextItemText, bean.getText());
            if (bean.isSelect()) {
                baseViewHolder.getView(R.id.tvSelTextItemText).setVisibility(View.INVISIBLE);
            } else {
                baseViewHolder.getView(R.id.tvSelTextItemText).setVisibility(View.VISIBLE);
            }
        }
    }
}
